﻿using System;
using CI.Misc;
using NUnit.Framework;
using System.IO;

namespace Globals.SystemTests
{
    [TestFixture]
    public class MesopotamiaInstallerTests
    {
        private MesopotamiaInstaller _mesopotmaiaInstaller;

        [SetUp]
        public void Setup()
        {
            _mesopotmaiaInstaller = new MesopotamiaInstaller();
        }

        /// <summary>
        /// check that their are not files in the destination folder
        /// </summary>
        [Test]
        public void RemoveRoboticsProxys_NoSimFiles()
        {
            // remove the files
            _mesopotmaiaInstaller.RemoveRoboticsProxys();

            // assert that they are removed
            foreach (string filename in _mesopotmaiaInstaller.RequiredFiles)
            {
                Assert.IsFalse(File.Exists(CI.Utils.RoboticsConfig.FindRoboticsFolders() + filename), "File exists and should not");
            }
        }

        [Test]
        public void RemoveOldFiles()
        {
            _mesopotmaiaInstaller.CleanOldFiles();
        }

        /// <summary>
        /// check that the files are in the destination folder
        /// </summary>
        [Test, Ignore("tests no longer revelent now that installation files are spread accross multiple projects")]
        public void CopyRoboticsProxys_FilesExisit()
        {
            // remove the files
            _mesopotmaiaInstaller.RemoveRoboticsProxys();

            string roboticsFolder = CI.Utils.RoboticsConfig.FindRoboticsFolders();
            string fileCheck;

            // assert that they are removed
            foreach (string filename in _mesopotmaiaInstaller.RequiredFiles)
            {
                fileCheck = roboticsFolder + "\\" + filename;
                Assert.IsFalse(File.Exists(fileCheck), "File exists and should not :" + fileCheck);
            }

            // copy the files
            _mesopotmaiaInstaller.CopyRoboticsProxys(Environment.CurrentDirectory);

            // assert that they are their
            foreach (string filename in _mesopotmaiaInstaller.RequiredFiles)
            {
                fileCheck = roboticsFolder + "\\" + filename;
                Assert.IsTrue(File.Exists(fileCheck), "File does not exist :"+fileCheck);
            }


        }
    }
}


